// var teamURL = "http://localhost:8080/hjcr-wechat/user/getUser";
var teamURL = "./json/team.json";
$(document).ready(function(){
  $.get(teamURL,{params:{userId:sessionStorage.userId}}, function(res){
    if(res.serviceResult){
      var data = res.resultParm.list;
      var info = res.resultParm;
      $(".prevName").text(info.firstUser.userName);//上级代理名字
      $(".topName").text(info.secondUser.userName);//顶级代理名字
      $(".firstNum").text(info.countFirstChildrenAgent);//一级代理人数
      $(".secondNum").text(info.countSecondChildrenAgent);//二级代理人数
      var html = "";
      for (var i = 0; i < data.length; i++) {
        html += 	'<a class="linkAgent" data-id="'+data[i].userId+'" href="teamAgent">'+
                    '<div class="option-item panel row">'+
                			'<img src="'+data[i].headImgUrl+'" class="avatar" alt="">'+
                			'<div class="user-info">'+
                				'<span class="username">'+data[i].userName+'</span>'+
                				'<br>'+
                				'<span class="text-color-1">拥有一级代理：'+data[i].firstAgentCounts+'人</span>'+
                			'</div>'+
                			'<img class="arrow" src="img/go.png" alt="">'+
                		'</div>'+
                  '</a>';
      }
      $(".option-panel").empty().append(html);
    }
  });
  $("body").find(".team").on('click',".linkAgent",function(){
    var id = $(this).attr("data-id");
    sessionStorage.agentId = id;
  });
});
